<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/4/20
  Time: 22:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script type="text/javascript" src="js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="//cdn.bootcss.com/json2/20160511/json_parse_state.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            testRequestBody();
        });
        function testRequestBody() {
            $.ajax(
                {
                    type: "POST",
                    url:"/spring/json/testRequestBody",
                    dataType: "json",
                    contentType: "application/json",
                    data: JSON.stringify({id:1,name:"Spring+MyBatis企业应用实践"}),
                    async: true,
                    success: function(data){
                        console.log(data)
                        $("#id").html(data.id);
                        $("#name").html(data.name);
                        $("#author").html(data.author);

                    },
                    error:function () {
                        alert("发送数据失败");
                    }
                }
            )
        }
    </script>
    <title>测试接收Json格式数据</title>
</head>
<body>
编号：<span id="id"></span><br>
书名：<span id="name"></span><br>
作者：<span id="author"></span><br>
</body>
</html>
